const path = require('path')


let profile = process.argv.find(arg => arg==='prod') ? 'prod' : 'dev' // prod dev

const version = require('fs').readFileSync(__dirname + '/.version', 'utf8')
const logLevel = 'debug'

const dbFile = 'app.sqlite'
const authFile = 'auth'

// dev config
const configDev = {
    port:  8080,
    configPath: './',
    webui: 'C:\\Users\\shanke\\WORK\\ppp\\control-server\\web'
}

// prod config
const configProd = {
    port: 6699,
    configPath: '/config',
    webui: '/app/web'
}

function getBaseConfig() {
    const baseConfig = {
        profile,
        logLevel,
        version,
        passkey: ''
    }
    if ('dev' === profile)
        return {
            ...baseConfig,
            ...configDev,
            authFileUrl: path.join(configDev.configPath, authFile),
            dbUrl: path.join(configDev.configPath, dbFile)
        }
    else if ('prod' === profile)
        return {
            ...baseConfig,
            ...configProd,
            authFileUrl: path.join(configProd.configPath, authFile),
            dbUrl: path.join(configProd.configPath, dbFile)
        }
}


const baseConfig = getBaseConfig()


module.exports = baseConfig